/**
 * 
 */
package com.cci.kangdao.context;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;


/**
 * @description:
 * @author: wang ying
 * @company: Persagy Technology Co.,Ltd
 * @since: 2022年1月14日 下午2:11:40
 * @version: V1.0
 **/
@Component
public class ApiApplicationContext implements ApplicationContextAware{

	private static ApplicationContext applicationContext = null;
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		
		ApiApplicationContext.applicationContext = applicationContext;
	}

	
	public static Object getBean(String name) {
		
		return applicationContext.getBean(name);
	}
	
	public static <T> T getBean(Class<T> clz) {
		
		return applicationContext.getBean(clz);
	}
	
	public static <T> T getBean(String name, Class<T> clz) {
		
		return applicationContext.getBean(name, clz);
	}
	
    public static String getProperties(String name){
        return applicationContext.getEnvironment().getProperty(name);
    }
}
